<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>PyTom: Install & Compile</title>
<link rel="stylesheet" type="text/css" href="./css/styles.css"></link>
</head>
<body>

<h2>Here you will find how to set up PyTom on your system</h2>
<h3 id="General">Get the PyTom release</h3>
<p align="justify">
Learn here how you can obtain the source code.
<h3 id="General">
	A zipped release
</h3>
You can download a zipped release file from <a href="XXX" target="_blank">sourceforge</a>.
<h3 id="General">
	Get a direct link into the GIT repository
</h3>
You can directly hook up into the release repository. This bears the great advantage that you will be able to immediatly install the latest release without having to change your environment. 
Open a terminal and change into a folder of your choice an run the following command:
<div class="codeFragment">
	<code>
        git clone http://git.code.sf.net/p/pytom/gitrepo pytom
    </code>
</div>
The above line will download the latest stabe (master) branch into the pytom folder. You must not use another folder-name for PyTom assumes it is installed into a "pytom" folder and will not work otherwise.
</p>
<h3 id="General">Dependencies</h3>
<p>You will need few other toolboxes installed on your system.</p>
<table border="1">
  <tr><td><b>GCC</b></td><td>The Gnu C Compiler</td></tr>
  <tr><td><b>Python</b></td><td>v2.6 or newer, including development includes and libraries (installation with --enable-shared)</td></tr>  
  <tr><td><b>LXML</b></td><td>Python XML library</td></tr>
  <tr><td><b>libxml2</b></td><td>Standard installation with dynamic libs</td></tr>
  <tr><td><b>libxstl</b></td><td>Standard installation with dynamic libs</td></tr>
  <tr><td><b>fftw3</b></td><td>with float and dynamic library support (installation with --enable-shared)</td></tr>
  <tr><td><b>boost</b></td><td>1.46 - only few headers</td></tr>
  <tr><td><b>swig</b></td><td>Glue interface between Python and C/C++</td>
  <tr><td><b>Numpy/SciPy</b></td><td>Python scientific library</td></tr>
  <tr><td><b>openmpi</b></td><td>for parallel processing</td></tr>
  </tr>
  <tr><td>or</td><td></td></tr>
  <tr><td><b>lam</b></td><td>for parallel processing</td></tr>
  <tr><td>OPTIONAL</td><td>but recomended</td></tr>
  <tr><td><b>IPython</b></td><td>Interactive Python</td></tr>
  <tr><td><b>PIL</b></td><td>Python Image Library</td></tr>
  <tr><td><b>MatPlotLib</b></td><td>Python plot library</td></tr>
  <tr><td><b>Epydoc</b></td><td>Python documentation library</td></tr>
</table>
<p>OS specific packages will be listed at OS specific details below. </p>
<p><b>Tested system setups</b>
  
</p>
<p><i>Kubuntu Linux</i>
  
  
</p>
<table border="1">
  <tr><td><b>GCC</b></td><td>4.4.3 or lower that supports C++ 98 the standard</td></tr>
  <tr><td><b>Python</b></td><td>v2.6.5</td></tr>  
  <tr><td><b>LXML</b></td><td>Python XML library</td></tr>
  <tr><td><b>libxml2</b></td><td>2.7.6</td></tr>
  <tr><td><b>libxstl</b></td><td>1.1.26</td></tr>
  <tr><td><b>fftw</b></td><td>3.2.4</td></tr>
  <tr><td><b>boost</b></td><td>1.46</td></tr>
  <tr><td><b>swig</b></td><td>1.3.40</td></tr>
  <tr><td><b>openmpi</b></td><td>1.5.4_0</td></tr>
  <tr><td><b>IPython</b></td><td>0.1</td></tr>
  <tr><td><b>PIL</b></td><td>1.1.7_3</td></tr>
  <tr><td><b>Epydoc</b></td><td>3.0.1</td></tr>
</table>

<p><i>OSX</i></p>

<table border="1">
  <tr><td><b>GCC</b></td><td>4.4.3 or lower that supports C++ 98 the standard</td></tr>
  <tr><td><b>Python</b></td><td>v2.6.7</td></tr>  
  <tr><td><b>LXML</b></td><td>2.3</td></tr>
  <tr><td><b>libxml2</b></td><td>2.7.8</td></tr>
  <tr><td><b>libxstl</b></td><td>1.1.26</td></tr>
  <tr><td><b>fftw</b></td><td>3.3</td></tr>
  <tr><td><b>boost</b></td><td>1.47.0</td></tr>
  <tr><td><b>swig</b></td><td>2.0.4</td></tr>
  <tr><td><b>openmpi</b></td><td>1.5.4_0</td></tr>
  <tr><td><b>IPython</b></td><td>0.11</td></tr>
  <tr><td><b>PIL</b></td><td>1.1.7_3</td></tr>
  <tr><td><b>Epydoc</b></td><td>3.0.1</td></tr>
</table>
<p>&nbsp;</p>
  <p><b>Compiling</b>
  </p>
  <p align="justify">
  Obtain a PyTom copy and rename the downloaded folder to <code>pytom</code>. Next, change into the pytom/pytomc folder. Know where all your libraries are locate. In case dynamic libraries and include files for the packages mentioned above were not installed into the system specific folder like <code>/usr/include</code> or <code>/lib</code>, you must specify them to the <code>compile.py</code> tool. 
    Type  
    <div class="codeFragment">
	<code>./compile.py</code>
	</div>
and a help will print all properties you can assign. Specify all paths as parameters to compile.py and run it with 
<div class="codeFragment"><code>--target all</code></div>
Compilation should succeed ( :) ). Binaries named <code>pytom</code> and <code>ipytom</code> will be written into 
<div class="codeFragment">
<code>PATH/pytom/bin</code>
</div>
<p align="justify">You can excecute these files from within this folder or you adjust your shell startup (e.g. <code>~/.bashrc</code>) to find it automatically for you.
</p>
<p><b>Compile scripts</b>
</p>
<i>Kubuntu Linux</i>
<br/>
<div class="codeFragment">
<code>
./compile.py <br/>
--includeDir /usr/include/python2.6 /usr/local/apps/openmpi-1.2.9/include /usr/include/boost/ <br/> 
/usr/lib/python2.6/dist-packages/numpy/core/include/numpy/ <br/>
--libDir /usr/local/apps/openmpi-1.2.9/lib /usr/lib <br/>
--dirPath /usr/local/apps/openmpi-1.2.9/bin <br/>
--pythonVersion 2.6 <br/>
--target all
</code>
</div>
<br/><br/>
<i>Debian 6</i>
<br/>
<div class="codeFragment">
<code>
./compile.py --libDir /lib /usr/lib --includeDir /include /usr/include/openmpi/ <br/>
/usr/include/python2.6 /usr/include/python2.6/numpy/  /usr/include/boost/ <br/>
--pythonVersion 2.6 --target all
</code>
</div>
<br/><br/>
<i>OSX</i><br/>
<div class="codeFragment">
<code>
./compile.py <br/>--libDir /opt/local/lib/ <br>
--includeDir /opt/local/include/ <br/>
/opt/local/include/openmpi/ /opt/local/include/boost <br/>
/opt/local/Library/Frameworks/Python.framework/Versions/Current/include/python2.6/<br/>
/opt/local/Library/Frameworks/Python.framework/Versions/Current/lib/python2.6/site-packages/numpy/core/include/numpy/ <br/>
--target all
</code>
</div>
<br/><br/>
Please note for the Python library and include paths: the path provided here are dependent on the current used Python vesion <code>2.6</code>.<br/>
If you use another version you will have to adjust the version number accordingly.

<p><strong>Setup your environment</strong></p>
<p>Once you successfully compiled PyTom, extend your <em>~/.bashrc</em> or <em>~/.cshrc</em> with the path to the PyTom excecuteables:</p>
<p><em>~/.bashrc</em></p>
<pre>export PATH '&lt;PathToPyTom&gt;/bin':$PATH</pre>
<p> <em>~/.cshrc</em></p>
<pre>setenv PATH='&lt;PathToPyTom&gt;/bin':$PATH</pre>
<p><strong>Check system setup</strong></p>
<p align="justify">In order to determine if your system is set up correctly, you can run <code>pytom/pytomc/check.py</code>. A correct PyTom set up should give something like:
<div class="codeFragment">
<code>
swigModules/_pytom_volume.so:<br/>
	swigModules/_pytom_volume.so (compatibility version 0.0.0, current version 0.0.0)<br/>
	/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 52.0.0)<br/>
	/Users/hrabe/develop/PyTomGIT/master/pytom/pytomc/libs/libtomc/libs/libtomc.so (compatibility version 0.0.0, current version 0.0.0)<br/>
	/opt/local/lib/libfftw3.3.dylib (compatibility version 7.0.0, current version 7.0.0)<br/>
	/opt/local/lib/libfftw3f.3.dylib (compatibility version 7.0.0, current version 7.0.0)<br/>
	/opt/local/Library/Frameworks/Python.framework/Versions/2.6/Python (compatibility version 2.6.0, current version 2.6.0)<br/>
	/opt/local/lib/libmpi.1.dylib (compatibility version 2.0.0, current version 2.2.0)<br/>
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)<br/>
</code>
</div>
<br/><br/>
Test the installation by running <code>ipytom</code> (in <code>pytom/bin</code>) and type
<div class="codeFragment">
<code>
import pytom # should not fail<br/>
from pytom_volume import read <br/>
read('')<br/>
#should give:<br/>
#RuntimeError: : Wrong file format or file doesn't exist!<br/>
</code>
</div><br/>
Congratulations, PyTom is fully installed on your machines!<br/><br/>

<p><b>Packages for OSX</b>
</p>
<p>OSX is a unix derivation and PyTom thus runs on these systems. However, you have to install more libraries manually as it is not shipped with the regular Linux tools. </p>
<p><i>1.</i> Install <a href="http://developer.apple.com/technologies/tools/"  target="_blank">XCode</a> to get all developer tools like GCC compiler... 
</p>
<p><i>2.</i> Install <a href="http://www.macports.org/"  target="_blank">MacPorts</a> to retrieve all these nitty Linux tools (Tested with 2.0.3 and working). You can alternatively use <a href="http://www.finkproject.org/"  target="_blank">Fink</a> to get these tools (Untested though).
</p>
<p><i>3.</i> Once MacPort is setup, open a terminal and run these scripts:
</p>
<div class="codeFragment">
<code>
sudo port selfupdate<br/>
sudo port install fftw-3 fftw-3-single<br/>
sudo port install libxml2 libxslt <br/>
sudo port install python26<br/>
sudo port install swig-python<br/>
sudo port install py26-lxml<br/>
sudo port install openmpi<br/>
sudo port install boost<br/>
sudo port install py26-pil<br/>
sudo port install py26-ipython<br/>
sudo port install py26-matplotlib<br/>
sudo port install py26-scipy<br/>
sudo port install py26-epydoc<br/>
</code>
</div>
After compilation is done (may take some time depending on your machine), you can specify the excecuteable name for <i>python</i> and <i>ipython </i> with 
<div class="codeFragment">
<code>
sudo port select --set python python26<br/>
sudo port select --set ipython ipython26
</code>
</div>
<p>because MacPorts does not generate these links automatically. </p>
<p><i> 4.</i>Get PyTom and compile as described above.
</p>
<p>&nbsp;</p>

<p><b>Packages for CentOS 6.1 final</b></p>
Use these commands below to install all required packages for CentOS 6.1 (final release).
<div class="codeFragment">
<code>
sudo yum install fftw-devel.x86_64<br/>
sudo yum install boost.x86_64<br/>
sudo yum install openmpi.x86_64<br/>
sudo yum install openmpi-devel.x86_64<br/>
sudo yum install boost.x86_64<br/>
sudo yum install boost-devel.x86_64 <br/>
sudo yum install openmpi-devel.x86_6<br/>
sudo yum install openmpi-devel.x86_64<br/>
sudo yum install python-devel.x86_64<br/>
sudo yum install scipy.x86_64<br/>
<br/><br/>
./compile.py --pythonVersion 2.6 --target all --libDir /usr/lib64/ /usr/lib64/openmpi/lib <br/>
--includeDir /usr/include/ /usr/include/python2.6 /usr/include/boost/ /usr/lib64/python2.6/site-packages/numpy/core/include/numpy/ /usr/include/openmpi-x86_64/  <br/>
--exeDir /usr/lib64/openmpi/bin
</code>
</div>

<a name="SH"><p><b>Note for compilation of SH Alignment since version 0.95</b></p></a>
<p>We are excited to integrate <a href="frm.html">SH Alignment</a> library into PyTom since version 0.95! Now FFTW3 is the only prerequisite. (Migration from FFTW2 to FFTW3 is done.) Once you have it, the compile command stays the same as stated above and SH Alignment will get compiled together with PyTom.
After the compilation is finished, you can check if SH Alignment is successfully installed by:
<div class="codeFragment">
<code>
pytom<br/>
>>> from sh_alignment.frm import frm_align
</code>
</div>
</p>

<a><p><b>Core dump error?</b></p></a>
<p>After a successful installation you want to use PyTom. However, you still get some core dump errors time to time? Like:
<div class="codeFragment">
<code>
*** glibc detected *** python: free(): invalid pointer: 0x00007f04ffcd64c0 ***<br/>
...<br/>
Aborted (core dumped)
</code>
</div>
Even though, this has nothing to do with PyTom itself. The exception raised from Python is not catched properly and the true error is hidden behind. We suspect this happends due to the Python version. Only 2.6.x has this issue. To avoid this, try to use Python 2.5 or 2.7.
</p>

<p>&nbsp;</p>
<p>For errors, check our <a href="./faq.html">FAQ</a> for known issues. </p>
</body>
</html>
